package GUI.iFrames;

import javax.swing.JButton;
import javax.swing.JTextField;

import GUI.iFrames.DataSourceComponents.DataSourcesInternalFrame;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * 20.12.2011(Enable Rip position correction)
 * @author Bunkowski
 */
public class AlignK0InternalFrame extends javax.swing.JInternalFrame {

	public static final long serialVersionUID = 1L;
	private JTextField txtAlignmentvalue;

	public AlignK0InternalFrame(final DataSourcesInternalFrame dataSourcesInternalFrame) {
		
		setClosable(true);
		setIconifiable(false);
		setMaximizable(false);
		setResizable(false);
		setTitle("Set Rip");
	

		getContentPane().setLayout(null);

		txtAlignmentvalue = new JTextField();
		txtAlignmentvalue.setBounds(10, 11, 75, 20);
		getContentPane().add(txtAlignmentvalue);
		txtAlignmentvalue.setColumns(10);

		JButton btnSet = new JButton("Set Rip");
		btnSet.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				try{
					
				double doubleAlignmentvalue = Double.parseDouble(txtAlignmentvalue.getText().replace(",","."));
				dataSourcesInternalFrame.setRipPositionsTo(doubleAlignmentvalue);
				}catch(NumberFormatException nfe){
					nfe.printStackTrace();
				}
				
				
			}
		});
		btnSet.setBounds(95, 10, 73, 23);
		getContentPane().add(btnSet);

		JButton btnRemoveButton = new JButton("Remove Rip Alignment");
		btnRemoveButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				dataSourcesInternalFrame.resetRipPositions();
			}
		});
		btnRemoveButton.setBounds(7, 42, 161, 23);
		getContentPane().add(btnRemoveButton);
	
		setLayer(2);
		
	}
}
